<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>窗口居中</title>
    <style>
        #wrap {
            /* border: 1px solid #ff0000; */
            position: absolute;
            width: 100px;
            height: 100px;
            left: 50%;
            top: 50%;

        }
        #box {
            background-color: #000000;
            width: 100px;
            height: 100px;
            position: absolute;
            left: -50%;
            top: -50%;
        }
    </style>
</head>
<body>
    <div id="wrap">
        <div id="box"></div>
    </div>
</body>
</html>